<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/common/plugin/tree/css/demo.css" type="text/css">
<link rel="stylesheet" href="${pageContext.request.contextPath }/static/common/plugin/tree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/sys/user/js/jquery.reveal.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/plugin/tree/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/plugin/tree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/plugin/tree/js/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/common/plugin/tree/js/jquery.ztree.exedit.js"></script>
<title>Insert title here</title>
<style type="text/css">
.ztree li button.switch {visibility:hidden; width:1px;}
.ztree li button.switch.roots_docu {visibility:visible; width:16px;}
.ztree li button.switch.center_docu {visibility:visible; width:16px;}
.ztree li button.switch.bottom_docu {visibility:visible; width:16px;}
</style>


<%-- <style type="text/css">
	body { font-family: "HelveticaNeue","Helvetica-Neue", "Helvetica", "Arial", sans-serif; }
	.big-link { display:block; margin-top: 100px; text-align: center; font-size: 70px; color: #06f; }
	ul{
		list-style:none;
		display:inline;
	}
</style> --%>
<script type="text/javascript">
var setting = {
		view: {
			dblClickExpand: false,
			showLine: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};

	var zNodes =${json};
	
	function onClick(e,treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		zTree.expandNode(treeNode);
	}

	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});
</script>
	<style type="text/css">
		div#rMenu {position:absolute; visibility:hidden; top:0; background-color: #555;text-align: left;padding: 2px;}
		div#rMenu ul li{
			margin: 1px 0;
			padding: 0 5px;
			cursor: pointer;
			list-style: none outside none;
			background-color: #DFDFDF;
		}
	</style>
</head>
<body>
<div style="margin:20px;"><h1><a href="${pageContext.request.contextPath }/course/CourseServlet?command=courseInItInsert " title="点击新增课程" style="text-decoration:none">课程管理</a></h1></div>
<hr>
	<div class="content_wrap" >
		<div class="zTreeDemoBackground left">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
			<form  action="${pageContext.request.contextPath }/course/CourseServlet?command=courseList" method="post" id="myform"  name="myform">
				课程名：<input type="text" name="submitName" value="${courseEntity.name }"/>
				操作者：<input type="text" name="submitOperateUserId" value="${courseEntity.operateUserId }"/>
				状态：<select name="SubmitState">
						<option value="" <c:if test="${courseEntity.state == 0 }">selected="selected"</c:if>>-全部-</option>
						<option value="1" <c:if test="${courseEntity.state == 1 }">selected="selected"</c:if>>-有效-</option>
						<option value="2" <c:if test="${courseEntity.state == 2 }">selected="selected"</c:if>>-无效-</option>
					</select>
					<input type="submit" value="查询"/>
			</form>
			<hr>
		<div class="zTreeDemoBackground right">
		<table  width="100%" border="1" align="right" cellpadding="0" cellspacing="0" height="40px">
			<tr style="text-align:center">
				<th>编号</th>
				<th>所属课程</th>
				<th>课程名</th>
				<th>操作者</th>
				<th>操作时间</th>
				<th>状态</th>
				<th>备注</th>
				<th>操作</th>
			</tr>
			<c:if test="${empty pageModel.list }">
				<td colspan="7" align="center">
					暂无数据显示！
				</td>
			</c:if>
			<c:if test="${!empty pageModel.list }">
				<c:forEach items="${pageModel.list }" var="course" varStatus="v">
					<tr align="center">
						<td>${v.count }</td>
						<td>
						<c:forEach items="${pageModel.list }" var="listName">
							<c:if	test="${listName.id  } ==  ${course.PId}">
								${course.name }
							</c:if>
							<c:if	test="${course.PId    } == '0' ">
								${course.name }
							</c:if>
						</c:forEach>
						</td>
						<td>${course.name }</td>
						<td>${course.operateUserId }</td>
						<td>${course.operateTime }</td>
						<td>${course.stateStr }</td>
						<td>${course.memo }</td>
						<td>
								<a href="${pageContext.request.contextPath }/course/CourseServlet?command=courseIntiUpdate&id=${course.id}">修改</a>|
								<a href="${pageContext.request.contextPath }/course/CourseServlet?command=courseDelete&id=${course.id}">删除</a>
						</td>
					</tr>
				</c:forEach>
			</c:if>
		</table>
	</div>
	<div style="float: right">
		<a href = "javascript:;" onclick="submitCondition(${pageModel.first});">首页</a>&nbsp;
		<a href = "javascript:;" onclick="submitCondition(${pageModel.pre});">上一页</a>&nbsp;
		第<select onchange="goPage(this)">
		<script>
			var pageNo = '${pageModel.pageNo}';
			var totalPage = '${pageModel.totalPage}';
			for (var i = 1; i <= totalPage; i++) {
				if (pageNo == i) {
					document.write('<option value="' + i + '" selected="selected">' + i + '</option>');
				} else {
					document.write('<option value="' + i + '">' + i + '</option>');
				}
			}
		</script>
		</select>页
		,共${pageModel.totalPage}页&nbsp;
		<a href = "javascript:;" onclick="submitCondition(${pageModel.next});">下一页</a>&nbsp;
		<a href = "javascript:;" onclick="submitCondition(${pageModel.last});">尾页</a>&nbsp;
		共${pageModel.allRecords }条记录
	</div>
</div>
</body>

<script type="text/javascript">
	function submitCondition(pageNo){
		document.myform.action="<%=request.getContextPath()%>/course/CourseServlet?command=courseList&pageNo="+pageNo;
		document.myform.submit();
	}
</script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/sys/user/js/list-user.js"></script>
</html>